﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.OracleClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Logistics.DataAccess
{
    public class OWR_FILE
    {
        public List<Model.OWR_FILE> GetList()
        {
            StringBuilder strSql = new StringBuilder("SELECT * FROM OWR_FILE ");
            using (DbDataReader dr = DBHelper.ExecuteReader(strSql.ToString()))
            {
                List<Model.OWR_FILE> lst = GetList(dr);
                return lst;
            }
        }

        public List<Model.OWR_FILE> User_GetList(string p_owr001)
        {
            string l_sql = "SELECT OWR_FILE.*  " +
                           "  FROM OWR_FILE " +
                           " WHERE OWR001 = '" + p_owr001 + "'";
            StringBuilder strSql = new StringBuilder(l_sql);
            using (DbDataReader dr = DBHelper.ExecuteReader(strSql.ToString()))
            {
                List<Model.OWR_FILE> lst = GetList(dr);
                return lst;
            }
        }

        #region 
        /// <summary>
        /// 由一行数据得到一个实体
        /// </summary>
        private Model.OWR_FILE GetModel(DbDataReader dr)
        {
            Model.OWR_FILE model = new Model.OWR_FILE();
            model.OWR001 = DBHelper.GetString(dr["OWR001"]);
            model.OWR002 = DBHelper.GetString(dr["OWR002"]);
            model.OWR003 = DBHelper.GetString(dr["OWR003"]);
            return model;
        }

        /// <summary>
        /// 由DbDataReader得到泛型数据列表
        /// </summary>
        private List<Model.OWR_FILE> GetList(DbDataReader dr)
        {
            List<Model.OWR_FILE> lst = new List<Model.OWR_FILE>();
            while (dr.Read())
            {
                lst.Add(GetModel(dr));
            }
            return lst;
        }
        #endregion
    }
}
